<?PHP

class news extends content
{
   var $category_parent;
	var $items;
	var $current_news;
	var $author_data;
	var $videos;
	function news()
	{
		mp('loading news');
	}
	
	
	function digest()
	{
		global $conf;

		$this->where['id']=$conf->qm[1];
		$this->get_content();
		$this->get_content_image();
		$this->current_news = $this->piece;
		
		$category=new content_category();
		$category->where['id']=$this->piece['category'];
		$category->get_category();
		
		if($category->piece['parent']>=18)
		{
			unset($category->where['id']);
			$category->where['id']=$category->piece['parent'];
			$category->get_category();
		 
		}
		//die($category->piece['id']);
		mp('got category');
		
		$this->get_videos($category->piece['id']);
		
		if($category->piece['type']=='video' && $category->piece['status']=='enabled')
		{
			mp('enabled video');
			$serial=unserialize($category->piece['serial']);
			$conf->style['masthead']=$category->piece['name'];
			$conf->style['background'].='background-image:url('.ap($serial["serial_style_background_image"]).');';
			$conf->style['background'].='background-color:#'.$serial["serial_style_background_color"].';';
			$conf->style['custom-masthead']=='color:#'.$serial["serial_style_masthead_color"].';';
			mp(ap($category->piece['image']));
				
			if(!empty($category->piece['image']))
			{
				$conf->style['masthead']='<img src="'.ap($category->piece['image']).'"/>';
			}
			
		}
		
		$this->display=TRUE;
		$this->category_parent = $category->piece;
		$conf->page_render='assets/pages/news.php';
	
	}
	function get_author_data()
	{

		$category=new content_category();
		$category->where['id']=$this->current_news['author'];
		$category->get_category();
		$this->author_data = $category->piece;
	}
	function get_content()
	{
   			
			$where=process_input($this->where);
     	

			$ij[0]=TRUE;
			$ij[1]='content';
			$ij[2][0]='*';						
			$ij[3][0]='id';
			$ij[3][1]='id';
				
		
		mp('getting content');
		$this->data=get_sql('content_post','id',$where,$this->options,$ij);
		
		$this->piece = current($this->data);
		$this->get_metadata($this->piece);
	}
	function get_content_image()
	{
		$where=process_input($this->where);
		$image = current(get_sql('content_image','id',$where,$this->options));		
		$this->piece = array_merge($this->piece,$image);
	}
	function get_items()
	{
		mp('grab items');
		$this->items=$this->get_posts($this->category_parent['id']);
	}
	
	function get_videos($cat)
	{
		mp('grab items');
		global $conf;
		unset($this->where);
		$this->where['category']=$cat;
		$this->where['type']='video';
		$this->videos=$this->get_category_items($cat);
	}
	
}	
	
	

?>
